﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using SiteChecker.Interfaces;
using SiteChecker.Helpers;

namespace SiteChecker.Models
{
    public class Site : INotifyPropertyChanged, ISiteStatus
    {
        private string _url;
        public string URL
        {
            get
            {
                return _url;
            }
            set
            {
                if (this._url != value)
                {
                    this._url = value;
                    this.OnPropertyChanged("URL");
                }
            }
        }
        private bool _robotsStatus;
        public bool RobotsStatus
        {
            get
            {
                return _robotsStatus;
            }
            set
            {
                if (this._robotsStatus != value)
                {
                    this._robotsStatus = value;
                    this.OnPropertyChanged("RobotsStatus");
                }
            }
        }
        private bool _allAgents;
        public bool AllAgents
        {
            get
            {
                return _allAgents;
            }
            set
            {
                if (this._allAgents != value)
                {
                    this._allAgents = value;
                    this.OnPropertyChanged("AllAgents");
                }
            }
        }
        private bool _allPaths;
        public bool AllPaths
        {
            get
            {
                return _allPaths;
            }
            set
            {
                if (this._allPaths != value)
                {
                    this._allPaths = value;
                    this.OnPropertyChanged("AllPaths");
                }
            }
        }
        public Site(string Url)
        {
            this.URL = Url;
            this.Refresh();
        }

        public void Refresh()
        {
            SiteStatusChecker checker = new SiteStatusChecker();
            checker.CheckSite(this);
        }

        #region INotifyPropertyChanged Members
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
